home *** CD-ROM | disk | FTP | other *** search
/ Windows 95 API Bible / Windows 95 API Bible 3 Disc Set.iso / Win32 API Bible Book 1 of 3 / CHAPTE20 / EX4.C < prev    next >
C/C++ Source or Header  |  1995-03-19  |  2KB  |  52 lines

  1. #include <genstub.c>
  2.  
  3. // Window message procedure.  Use program from GetPrivateProfileInt as base.
  4.  
  5. LRESULT CALLBACK WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
  6. {
  7.    char szBuffer[65];
  8.    switch (uMsg)   // process Windows messages
  9.    {
  10.        case WM_COMMAND:
  11.               switch ( LOWORD( wParam ) )
  12.                   {
  13.                      case IDM_TEST: 
  14.                          wsprintf(szBuffer, "%d Ticks have passed.", GetTickCount());
  15.                          WritePrivateProfileString( "TestSection",             // Section name
  16.                                                     "TickString",              // Key name
  17.                                                     szBuffer,                  // Value to store
  18.                                                     "YOUR.INI" );              // INI file name 
  19.                          InvalidateRect( hWnd, NULL, TRUE );
  20.                          UpdateWindow( hWnd );
  21.                          break;
  22.                      case IDM_EXIT:
  23.                          DestroyWindow( hWnd );
  24.                          break;
  25.                   }
  26.                   break;
  27.        case WM_PAINT:
  28.             {
  29.                 PAINTSTRUCT ps;
  30.                 GetPrivateProfileString( "TestSection",          // Section name
  31.                                          "TickString",           // Key name
  32.                                          "TickString Not Set",   // Default return value
  33.                                          szBuffer,               // Buffer
  34.                                          sizeof( szBuffer ),     // Buffer size
  35.                                          "YOUR.INI" );           // Name of INI file
  36.                 BeginPaint( hWnd, &ps );
  37.                 TextOut( ps.hdc, 0, 0, szBuffer, lstrlen( szBuffer ) );
  38.                 EndPaint( hWnd, &ps );
  39.             }
  40.             break ;
  41.  
  42.        case WM_DESTROY: 
  43.             PostQuitMessage( 0 );
  44.             break;
  45.        default:
  46.             return DefWindowProc( hWnd, uMsg, wParam, lParam );
  47.    }
  48.    return( 0L ) ;
  49. }
  50.  
  51. #include <about.c>
  52.